var sharestateID;
function share() {
    sharestateID=$(this).parent().parent().attr("id");
    $('#myModal').modal('show')
}

function sendforward() {       //模态框的转发按钮点击后的事件
    var content = $("#forwardcontent").html();
    console.log("评论内容：" + content);

    console.log("动态id"+sharestateID);
    $.post("forwardstate", {       //ajax 请求发送到pubeva
        stateid:sharestateID,
        content: content
    }, function (data, textStatus) {
        console.log(data.result);
        if (data.result) {       //成功后，修改界面显示,构建转发节点
            var $root = $("<div class=\"h-75\" style=\"padding-bottom: 100px\"></div>");
            var $medio=$("<div class=\"media\">\n" +
                "                        <img class=\"mr-3 rounded-circle\" src=\"image/userimage.png\" alt=\"Generic placeholder image\"\n" +
                "                             style=\"max-width: 50px;max-height: 50px\">\n" +
                "                        <div class=\"media-body\">\n" +
                "                            <h5 class=\"mt-0\">zgw</h5>\n" +
                "                            <span class=\"small\"><%=new Date()%></span>\n" +
                "                        </div>\n" +
                "                    </div>")
            $root.append($medio);
            var $forward_eva=$("<span class=\"d-block\" style=\"padding: 5px\">这里是转发并评论的内容！</span>");
            $root.append($forward_eva);

            var $forward_content=$("<div class=\"w-100 forwardedstate\">\n" +
                "\n" +
                "                        <h6 class=\"strong\">@网络冷眼</h6>\n" +
                "                        <span class=\"d-block\" style=\"padding: 5px\">这里是动态内容，拉啦啦！</span>\n" +
                "                        <video  controls class=\"mw-100 mx-auto\">\n" +
                "                            <source src=\"video/dayandnight.mp4\" type=\"video/mp4\">\n" +
                "                        </video>\n" +
                "\n" +
                "                    </div>\n" +
                "\n" +
                "                    <hr/>");

            $root.append($forward_content);

            var $state_tail=$("<div class=\"state-tail clearfix \" style=\"margin-top: 20px\">\n" +
                "                        <img src=\"image/dianzan.png\" alt=\"好吃\" class=\"dianzan float-left mutual\"\n" +
                "                             style=\"max-width: 25px;max-height: 25px;margin-left: 20px;cursor: pointer\">\n" +
                "                        <p class=\"count small float-left text-muted\" style=\"margin-top: 5px\">1000</p>\n" +
                "                        <p class=\"small float-left text-muted\" style=\"margin-top: 5px\">人觉得好吃</p>\n" +
                "                        <img src=\"image/evaluate.png\" alt=\"评论\" class=\"evaluate float-left mutual\"\n" +
                "                             style=\"max-width: 25px;max-height: 25px;margin-left: 20px;cursor: pointer\">\n" +
                "                        <img src=\"image/share.png\" alt=\"分享\" class=\"share float-left mutual\"\n" +
                "                             style=\"max-width: 25px;max-height: 25px;margin-left: 20px;cursor: pointer\">\n" +
                "                    </div>");

            $root.append($state_tail);

            var $eva_list=$("<ul class=\"list-group eva_list\"></ul>");

            $root.append($eva_list);
            var $eva_input=$("<div class=\"d-block evaluate_content border border-info rounded w-100\" contenteditable=\"true\"\n" +
                "                     aria-placeholder=\"评论\" ></div>\n" +
                "                <img src=\"image/emoji.png\" class=\"emoji_btn\">\n" +
            "                <button class=\"btn btn-outline-success float-right eva_btn\">评论</button>");
            $root.append($eva_input);
            $root.hide();       //先隐藏
            $(".state_container").prepend($root);

            $("#forwardcontent").html("");
            $("#myModal").modal('hide');
            $root.show("slow"); //慢慢显示出来，这样有动画效果
        } else {
            alert("发生错误，请重试");
        }
    }, "json");
}

function evafocus() {
    $(this).parent().next().next().focus(); //设置点击评论小图片是评论输入框自动获得焦点
}


//让广伟解决此BUG     我自己已解决
var has_dianzan = false;
function dianzan() {
    //alert("用户点赞了");
    var srcvalue = $(this).attr("src");
    var s=
    console.log(srcvalue);
    if (srcvalue == "image/dianzan.png") {
        $(this).attr("src", "image/dianzan2.png")
        var s = $(this).next().text();
        var count = parseInt(s) + 1;
        $(this).next().text(count.toString());
        has_dianzan = true;
    } else {
        $(this).attr("src", "image/dianzan.png")
        var s = $(this).next().text();
        var count = parseInt(s) - 1;
        $(this).next().text(count.toString());
        has_dianzan = false;
    }

}